

FUNCTION HexToDec(cHex)

     LOCAL cDig
     LOCAL nFor, nLen, nVal, nDig

     cHex := Upper(cHex)
     nVal := 0
     nLen := len(cHex)

     FOR nFor := 1 TO nLen

          cDig := Substr(cHex, nLen-nFor+1, 1)

          DO CASE
          CASE IsDigit(cDig)
               nDig := Val(cDig)
          CASE cDig$"ABCDEF"
               nDig := Asc(cDig)-55
          OTHERWISE
               RETU 0
          ENDCASE

          nVal += nDig*(16**(nFor-1))

     NEXT

RETURN Int(nVal)
